<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>管理后台</title>
    <link rel="stylesheet/less" href="../../../static/css/index.less"/>
    <link rel="stylesheet" href="../../../static/layui/css/layui.css"/>
    <link rel="stylesheet" href="../../../static/css/jquery.pagination.css"/>
    <script src="../../../static/js/jquery-1.12.3.js"></script>
    <script src="../../../static/js/less.min.js"></script>
    <script src="../../../static/layui/layui.js"></script>
    <script src="../../../static/js/ajaxfileupload.js"></script>
    <script src="../../../static/layer/layer.js"></script>
    <SCRIPT language=javascript src="../../static/layer/layer.js"></SCRIPT>
</head>
<style>

</style>
<body class="layui-layout-body">

{% include "/admin/top.html" %}
{% include "/admin/left.html" %}
<div id="box" class="fl">
    <div class="content" style="height: 100%">
        <h3 style="color:  #3D89CB">充值卡列表</h3>
       <div class="search" style="text-align: center">


            <button class="s_button" style="color: white;background-color: #3D89CB;margin-right: 100px ;float: right" onclick='location.href="/admin/recharge/newly.html"'>
                新增
            </button>
            {#                    </form>#}
        </div>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <thead>
            <tr>
                <th width="8%">充值ID</th>
                <th width="12%">充值名称</th>
                <th width="8%">洗车次数</th>
                <th width="8%">售价</th>
                <th width="8%">原价</th>
                <th width="8%">有效天数</th>
                <th width="8%">限购次数</th>
                <th width="8%">排序</th>
                <th width="10%">创建时间</th>
                <th width="8%">状态</th>
                <th width="12%">操作</th>
            </tr>
            </thead>

            <tbody>
            <tr>
                {% if res['code']==400 %}
                    <tr class="color2">
                        <td colspan=8 align="center">暂无数据</td>
                    </tr>
                {% elif res['code']==200 %}
                    {% for data in res['data'] %}

                        <tr>
                            <td>{{ data.id }}</td>
                            <td>{{ data.name }}</td>
{#                            <td>{{ data.period }}天</td>#}
                            <td>{{ data.num }}</td>
                            <td><span style="color: red">{{ data.price }}元</span></td>
                            <td>{{ data.initial_price }}元</td>
                            <td>{{ data.stopTime }}</td>
                            <td>{% if data.property==0 %}
                                不限购
                            {% else %}
                                {{ data.property }}
                            {% endif %}
                            </td>
                            <td>{{ data.weight }}</td>
                            <td>{{ data.addTime }}</td>
                            <td>
                                {% if data.status==0 %}
                                    禁用
                                {% elif data.status==1 %}
                                    激活

                                {% endif %}
                            </td>
                            <td>
                                <button><span style="color: green"><a
                                        href="/admin/recharge/edit.html?rechargeId={{ data.id }}">编辑</a></span>
                                </button>
                                {% if data.status == 0 %}
                                    <button class="ccc">
                                        <a href="#" onclick="start({{ data.id }})">启用</a>
                                    </button>
                                {% elif data.status == 1 %}
                                    <button class="green">
                                        <a href="#" onclick="stop({{ data.id }})">禁用</a>
                                    </button>
                                {% endif %}
                                <button class="red">
                                    <a href="#" onclick="delete_store({{ data.id }})">删除</a>
                                </button>
                            </td>

                        </tr>
                    {% endfor %}
                {% endif %}

            </tbody>
        </table>


    </div>
</div>
</div>

</body>
</html>

<script>
    function stop(id) {
        layer.open({
            content: '你确定禁用',
            btn: ['确认', '取消'],
            shadeClose: false,
            yes: function () {
                $.ajax({
                    url: '/admin/recharge/stop',
                    type: 'post',
                    data: {
                        'rechargeId': id
                    },
                    dataType: 'json',
                    success: function (msg) {
                        if (msg.status == 1) {
                            layer.msg("操作成功！", {time: 2000}, function () {
                                window.location.href = location.pathname;
                            });


                        } else {
                            layer.msg("操作失败！");
                        }
                    }
                });
            }
        });
    }
    function start(id) {
        layer.open({
            content: '你确定激活',
            btn: ['确认', '取消'],
            shadeClose: false,
            yes: function () {
                $.ajax({
                    url: '/admin/recharge/start',
                    type: 'post',
                    data: {
                        'rechargeId': id
                    },
                    dataType: 'json',
                    success: function (msg) {
                        if (msg.status == 1) {
                            layer.msg("操作成功！", {time: 2000}, function () {
                                window.location.href = location.pathname;
                            });


                        } else {
                            layer.msg("操作失败！");
                        }
                    }
                });
            }
        });
    }

    function delete_store(id) {
        layer.open({
            content: '你确定删除',
            btn: ['确认', '取消'],
            shadeClose: false,
            yes: function () {
                $.ajax({
                    url: '/admin/recharge/delete',
                    type: 'post',
                    data: {
                        'rechargeId': id
                    },
                    dataType: 'json',
                    success: function (msg) {
                        if (msg.status == 1) {
                            layer.msg("操作成功！", {time: 2000}, function () {
                                window.location.href = location.pathname;
                            });


                        } else {
                            layer.msg("操作失败！");
                        }
                    }
                });
            }
        });
    }

</script>


